
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 1289. -- [CTSC2009]移盘子 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>1289: [CTSC2009]移盘子</h2><span class=green>Time Limit: </span>30 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>162 MB<br><span class=green>Submit: </span>32&nbsp;&nbsp;<span class=green>Solved: </span>19<br>[<a href='submitpage.php?id=1289'>Submit</a>][<a href='problemstatus.php?id=1289'>Status</a>][<a href='bbs.php?id=1289'>Discuss</a>]</center><h2>Description</h2><div class=content><p>已知有三根柱子，分别记为A，B和C。初始状态时A上放有N个盘子，而B和C两个柱子上没有放任何盘子。你每次能做的移动操作就是把某根柱子最上面的一个盘子拿下来，然后放到另一个柱子上。盘子有三类，分别用1，2，3来表示。你的目标是，让所有1类盘子最终放在A上，让所有2类盘子最终放在B上，所有3类盘子最终放在C上。现在让你求出实现上述目标总共最少需要多少次移动？</p></div><h2>Input</h2><div class=content><p>第一行包含一个整数N，为盘子的总数。第二行有N个数，每个数只能是1，2，3之一。这N个数表示在初始状态时第一个柱子上所有盘子的类型，按照从上往下的顺序。</p></div><h2>Output</h2><div class=content><p>只包含一个数，即最少的移动次数。</p></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>5<br />
1 2 1 3 3<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>8<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p><img border="0" alt="" src="images/1289.jpg" />&nbsp;</p><br />
<p></p><br />
<p><span style="font-size: 12pt">对于</span><span style="font-size: 12pt">100%</span><span style="font-size: 12pt">的数据，</span><i><span style="font-size: 12pt">N</span></i><span style="font-size: 12pt"> &le; 1000</span></p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search='></a></p></div><center>[<a href='submitpage.php?id=1289'>Submit</a>][<a href='problemstatus.php?id=1289'>Status</a>][<a href='bbs.php?id=1289'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
